#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>


int main(int argc, char *argv[])
{
	int cfd;
	char buf[200];
	struct sockaddr_in srv_addr;

	srv_addr.sin_family = AF_INET;
	srv_addr.sin_port = htons(8888);
	srv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	//inet_pton(AF_INET, "127.0.0.1", &srv_addr.sin_addr.s_addr);

	//1.创建套接字
    cfd = socket(AF_INET , SOCK_STREAM,0);
    if(cfd == -1)
    {
        perror("socket");
        return -1;
    }

	if( connect(cfd, (struct sockaddr*)&srv_addr, sizeof(srv_addr)) == -1)
	{
		perror("connect");
		return -1;
	}
	printf("连接成功，请输入发送信息：\n");
	while (1) 
	{	
		printf("");
		int n;
		scanf("%d", n);
		write(cfd, buf, sizeof(n));
		
	}

}
